﻿Public MustInherit Class ArgumentBaseVm
    Inherits ViewModelBase

    Public Overridable Sub Init(token As TokenBaseVm, obj As RawObjectVm, arg As ArgumentDefinition, value As String)
        Me.Token = token
        mObj = obj
        mArg = arg
        mValue = value
    End Sub

    Protected mObj As RawObjectVm
    Protected mArg As ArgumentDefinition

    Public Property Token As TokenBaseVm


    Public Overridable ReadOnly Property Name As String
        Get
            Return mArg.Name
        End Get
    End Property

    Public Overridable ReadOnly Property Index As Integer
        Get
            Return mArg.Index
        End Get
    End Property

    Public Overridable ReadOnly Property Type As String
        Get
            Return mArg.Type.ToString
        End Get
    End Property

    Public ReadOnly Property RawObjectVm As RawObjectVm
        Get
            Return mObj
        End Get
    End Property

    Public ReadOnly Property RawObject As RawObject
        Get
            Return mObj.RawObject
        End Get
    End Property

    Private mValue As String
    Public Overridable Property Value As String
        Get
            Return mValue
        End Get
        Set(value As String)
            If value <> mValue Then
                mValue = value
                Token.SetArgumentValue(Index, value)
                RaisePropertyChanged("Value")
                'ObjectChangeManager.Instance.NotifyObjectChanged(Me.RawObject, Me.RawObjectVm)
                RawObjectVm.NotifyObjectChanged(False)
            End If
        End Set
    End Property
End Class
